package com.cssnj.portal.web.query;

import com.cssnj.portal.domain.common.UserInfo;
import com.cssnj.portal.service.query.Query22Service;
import io.predictech.framework.domain.common.JsonRequest;
import io.predictech.framework.domain.exception.BaseException;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.sql.SQLException;

@Controller
@RequestMapping("/query/query22")
public class Query22Controler {

    @Autowired
    Query22Service query22Service;

    @RequestMapping({"/init.do"})
    public ModelAndView init(@ModelAttribute JsonRequest jsonRequest) throws BaseException, SQLException {
        ModelAndView modelAndView = new ModelAndView("query/query22");
        UserInfo userInfo = (UserInfo) SecurityUtils.getSubject().getPrincipal();
        jsonRequest.getReqData().put("userInfo", userInfo);
        modelAndView.addAllObjects(query22Service.init(jsonRequest).getRepData());
        return modelAndView;
    }
}
